﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton;

namespace MwanaDOC
{
    public partial class frmDialog : ComponentFactory.Krypton.Toolkit.KryptonForm
    {
        private string cod;
        Materia mat = new Materia();

        public frmDialog()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterParent;
        }

        public string Message
        {
            get { return this.cod; }
            set
            {
                cod = value;
                
            }
        }

        private void getListaDisciplina()
        {
            System.Data.SQLite.SQLiteDataReader lstDisciplinas = null;

            lstDisciplinas = mat.getListaDisciplinas();
            cbxDisciplina.Items.Add("<Escolher>");
            while (lstDisciplinas.Read())
            {
                cbxDisciplina.Items.Add(lstDisciplinas.GetString(1));
            }
            cbxDisciplina.SelectedItem = "<Escolher>";


            //cbxDisciplina.DataSource = lstDisciplinas;
            //cbxDisciplina.DisplayMember = "Materia.Nome";
            //cbxDisciplina.ValueMember = "Materia.Nome";
        }

        private void frmDialog_Load(object sender, EventArgs e)
        {
            getListaDisciplina();
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cbxDisciplina.SelectedItem != "<Escolher>")
            {
                try
                {
                    //Message = int.Parse(cbxDisciplina.SelectedValue.ToString());
                    Message = cbxDisciplina.SelectedItem.ToString();
                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex1)
                {
                    this.DialogResult = DialogResult.Cancel;
                    LogToFile lg = new LogToFile();
                    lg.log("frmDialog", "btnOk_Click", ex1.Message, ex1.StackTrace);
                }
            }
            
            
        }

    }
}
